/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package jtablecolspan;

import java.awt.Component;
import java.awt.Graphics;
import java.awt.Rectangle;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;

/**
 *
 * @author jbf
 */
class MyTableCellRenderer extends DefaultTableCellRenderer {

    private int tableWidth;
    private int x;
    public MyTableCellRenderer() {
    }

    @Override
    public void setBounds(int x, int y, int width, int height) {
        this.x= x;
        super.setBounds( 0, y, tableWidth, height );
    }

    @Override
    public void paint(Graphics g) {
        g.translate( -x, 0);
        super.paint(g);
    }



    @Override
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
        this.tableWidth= table.getWidth();
        return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
    }



}
